(function(){
	if(!window.cell) window.cell={};
	if(!window.cell.dialog) window.cell.dialog={};
	if(!window.$dialog) window.$dialog = cell.dialog = function(obj) {
		if ( window == this || !this.init ){
			return new cell.dialog(obj);
		}
		return this.init(obj);
	}
	cell.dialog.fn = cell.dialog.prototype = {
		svcPrompt:Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService),
		version: "1.0.0",
		init:function(obj){
			if(!obj) return;
			if(!obj.title) obj.title="Untitle";
				this.title=obj.title;
			if(!obj.text) obj.text="";
				this.text=obj.text;
			this.chk=obj.chk;
		},
		alert:function(){
			if(!this.chk){
				this.svcPrompt.alert(window, this.title, this.text);
			}else{
				if(!this.chk.text) this.chk.text="";
				if(!this.chk.val) this.chk.val=false;
				return this.svcPrompt.alertCheck(window, this.title, this.text, this.chk.text, {value:this.chk.val});
			}
		},
		confirm:function(){
			if(!this.chk){
				return this.svcPrompt.confirm(window, this.title, this.text);
			}else{
				if(!this.chk.text) this.chk.text="";
				if(!this.chk.val) this.chk.val=false;
				var chk={value:this.chk.val}
				var flag=this.svcPrompt.confirmCheck(window, this.title, this.text, this.chk.text, chk);
				return {
					value: flag,
					status: chk.value,
					state: chk.value,
				}
				//alert(chk.value)
//				return this.svcPrompt.confirmCheck(window, this.title, this.text, this.chk.text, {value:this.chk.val});
			}
		},
	}
})();
